package com.fit.pages.company;

import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.fit.annotations.AdminAccess;
import com.fit.annotations.UserAccess;
import com.fit.dao.company.CompanyDAO;
import com.fit.entities.Company;
import com.fit.pages.Confirmation;

@AdminAccess
public class Details {

	@Property
	@Persist
	private Company company;
	
	@Inject
	private CompanyDAO companyDAO;
	
	@InjectPage
	private Confirmation confirmation;

	Object onActivate(Long id) {
		confirmation.setConfirmation("");
		confirmation.setError("");
		company = companyDAO.findById(id);
		if (company == null) {
			confirmation.setError("Error");
			return confirmation;
		}
		return null;

	}

}
